package com.cutJar.core.impl;

import com.conf.log.LOG;
import com.conf.log.impl.LogImpl;
import com.cutJar.Exception.CutNullException;
import com.cutJar.Exception.ResourceNullException;
import com.cutJar.core.AbstractCutJARImpl;
import com.cutJar.core.AbstractMachining;
import com.cutJar.core.CutJAR;
import com.cutJar.util.Resource;
/**
 * <b>主要是剪切rt和charsets<b>
 * @author 威 
 * <br>2018年3月31日 下午5:24:11 
 */
public class CutJARImpl_Main extends AbstractCutJARImpl {
	private CutJAR cutJAR;
	private String jrePath;
	public CutJARImpl_Main param(String jrePath){
		this.jrePath = jrePath;
		return this;
	}
	public CutJARImpl_Main cutPre() throws ResourceNullException{
		AbstractMachining machining = new MainMachiningImpl();
		machining.configure("rt", Resource.getResurceToString("pre", "class.txt"));
		machining.cutPreStart();
		machining.logResultInfo();
		return this;
	}
	public void cutStart(){
		cutJAR = new CutJAR();
		try {
			//剪切rt
			cutJAR.configure(jrePath, Resource.getResurceToString("pre", "rt")).cutStart();
			//剪切charsets
			cutJAR.configure(jrePath, Resource.getResurceToString("pre", "charsets")).cutStart();
		} catch (CutNullException | ResourceNullException e) {
			LogImpl.getInstance().log(LOG.ERROR, e.getMessage());
		}
	}
}
